package com.evildog.workspace.gateway.util;

import com.evildog.workspace.gateway.props.IgnoreUrlsProperties;
import org.springframework.util.AntPathMatcher;
import org.springframework.util.PathMatcher;

public class IgnoreUtil {

    public static boolean isSkip(String path, IgnoreUrlsProperties ignoreUrlsProperties) {
        PathMatcher pathMatcher = new AntPathMatcher();

        return IgnoreUrlsProperties.getDefaultSkipUrls().stream().anyMatch(pattern -> pathMatcher.match(pattern, path))
                || ignoreUrlsProperties.getSkipUrls().stream().anyMatch(pattern -> pathMatcher.match(pattern, path));
    }
}
